package com.gxa.controller;

import com.gxa.common.LayR;
import com.gxa.common.R;
import com.gxa.param.NoticeParam;
import com.gxa.pojo.Role;
import com.gxa.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;


    /**
     * 角色列表
     * @return
     */
    @GetMapping("/list/page")
    public String list(){
        return "role/role-list";
    }

    @PostMapping("/list/data")
    @ResponseBody
    public LayR  listData(NoticeParam param){
        return roleService.list(param);
    }

    @GetMapping("/add/page")
    public String addPage(){
        return "role/role-add";
    }

    @PostMapping("/add/do")
    @ResponseBody
    public R add(Role role){
        return roleService.add(role);
    }

    @PostMapping("/delete")
    @ResponseBody
    public R delete(@RequestParam("ids[]") String[] ids){
        return roleService.deleteAll(ids);
    }

    @PostMapping("/deleteid")
    @ResponseBody
    public R deleteid(Integer role_id){
        return roleService.deleteid(role_id);
    }
}
